<?php
/* wwwschool project
Copyright (C) 2009  Phillip Aldridge
Email : info@imi21.com
Web site http://www.imi21.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/**
 *
 *  wwwschool project
 *  File : WS3session.php
 *     
 */  


 
 class WS3_Session {
	const
	  VALID			  = 'VALID',
		CREATE			= 'CREATE',
		USER_IP			= 'USER_IP',
		USER_ID			= 'USER_ID',
		USER_TYPE		= 'USER_TYPE',
    USER_NAME		= 'USER_NAME',		
		NAV					= 'USER_BROWSER',
		TIMEOUT			= 'TIMEOUT',
		REFERER			= 'REFERER';
    
   public function __construct() {

    $this->start();
   }
   
   public function __destruct() {
   //$_SESSION = array();
	 //session_regenerate_id(false);
   }
   
   protected function start() {
      session_name("wwwschool");     
     @session_start();
      
     $this->check();
     //$_SESSION[self::VALID] = false;
   }
   
  protected function check() {
      if( !isset( $_SESSION[self::VALID] ) ) $_SESSION[self::VALID] = false;
      //$_SESSION[self::VALID] = false;  
   }

  //    
   function inValidate() {
    $_SESSION[self::VALID] = false;
   }    
   
  //       
   public function setValid( $id, $type="0", $first_name="", $last_name="" ) {
    $_SESSION[self::USER_ID] = $id;
    $_SESSION[self::USER_TYPE] = $type;
    $_SESSION[self::USER_NAME] = $first_name." ".$last_name;
    $_SESSION[self::VALID] = true;
   }
   
  //    
  public function userID() {  
      return $_SESSION[self::USER_ID];
   }
   
  //    
  public function userName() {  
      return $_SESSION[self::USER_NAME];
   }
   
  //    
  public function isValid() {  
      return $_SESSION[self::VALID];
   }
   
  // 
  public function userType() {  
      return $_SESSION[self::USER_TYPE];
   }   
 }
 
 ?>